//
//  SASecurityManagerViewController.m
//  SunOn
//
//  Created by RazeenCheng on 2017/5/3.
//  Copyright © 2017年 NeoZhang. All rights reserved.
//

#import "SASecurityManagerViewController.h"
#import "SACompanyProfileListTableViewCell.h"

#import "SAChangePhoneViewController.h" // 修改绑定手机
#import "SAChangePasswordViewController.h" // 修改密码
#import "SAForgetPSWFirstStepViewController.h" // 忘记密码

@interface SASecurityManagerViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *tableView;


@end

@implementation SASecurityManagerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 1) {
        // 分割线
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SeparatorCell" forIndexPath:indexPath];
        return cell;
    } else {
        SACompanyProfileListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SACompanyProfileListTableViewCell" forIndexPath:indexPath];
        [cell configCellWithRow:indexPath.row withType:@"SecurityManager"];
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 1) {
        return 10;
    } else {
        return 54;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = indexPath.row;
    
    if (row == 0) {
        // 修改绑定手机
        SAChangePhoneViewController *changePhoneVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SAChangePhoneViewController"];
        [self.navigationController pushViewController:changePhoneVC animated:YES];
    } else if (row == 2) {
        // 修改密码
        SAChangePasswordViewController *changePasswordVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SAChangePasswordViewController"];
        [self.navigationController pushViewController:changePasswordVC animated:YES];
    } else if (row == 3) {
        // 忘记密码
        UIStoryboard *login = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
        SAForgetPSWFirstStepViewController *forgetPasswordVC = [login instantiateViewControllerWithIdentifier:@"SAForgetPSWFirstStepViewController"];
        [self.navigationController pushViewController:forgetPasswordVC animated:YES];
    }
}

@end
